﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/EditMaster.Master" AutoEventWireup="true"
    CodeBehind="EditPosts.aspx.cs" Inherits="BugSysSolution.DataManagement.EditPosts" %>

<%@ Register TagPrefix="ajaxpage" Src="~/UserControls/AjaxPaging.ascx" TagName="Paging" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div>
        <table class="tab">
            <tr>
                <td>
                    类别:
                </td>
                <td>
                    <%--<select id="sel_bugtype" onchange="ChangeSel(this);">
                    </select>--%>
                    <asp:DropDownList ID="ddl1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddl1_SelectedIndexChanged">
                    </asp:DropDownList>
                </td>
                <td>
                    标题:<%--<input id="txt_name" />--%>
                    <asp:TextBox ID="txt_bugname" runat="server"></asp:TextBox>
                </td>
                <td>
                    <%--<input type="button" id="btn_search" value="Search" onclick="SearchBug();" />--%>
                    <asp:Button runat="server" ID="btn_search" Text="Search" CssClass="btn" OnClick="btn_search_Click" />
                </td>
            </tr>
        </table>
        <table class="tab">
            <asp:Repeater ID="rep1" runat="server">
                <HeaderTemplate>
                    <tr>
                        <td>
                            ID
                        </td>
                        <td>
                            Title
                        </td>
                        <td>
                            Content
                        </td>
                        <td>
                            Edit
                        </td>
                    </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <%# Eval("id") %>
                        </td>
                        <td>
                            <%# Eval("title") %>
                        </td>
                        <td>
                            <%# Eval("contents") %>
                        </td>
                        <td>
                            <a tag='<%# Eval("id") %>' onclick="EditClick(this);" style="cursor: pointer" href="#">
                                Edit</a> <a tag='<%# Eval("id") %>' onclick="DelClick(this);" style="cursor: pointer"
                                    href="#">Delete</a>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
            <tbody id="tbody">
            </tbody>
        </table>
        <%--        <div style="width: 100%; height: 20px; position: relative; top: 50%">
            <ajaxpage:Paging ID="ajaxpaing" runat="server" />
        </div>--%>
    </div>
    <script type="text/javascript">
        var requestUrl = "../RequestAjaxPage/BugAjaxPage.aspx";
        //        var p = new ajaxpaging(4, requestUrl, loaddata);
        //        var bugtype = 0;
        //        SendAjax("get", requestUrl, { tag: 'getbuglist', ran: Math.random(), bugtype: bugtype }, "json", function (data) {
        //            if (data == null) {
        //                return;
        //            }
        //            p.Init(data);
        //        });

        //        function loadSelect() {
        //            SendAjax("get", "../RequestAjaxPage/BugTypeAjaxPage.aspx", { ran: Math.random(), tag: "getalltype" }, "", function (data) {
        //                if (data == null) {
        //                    return;
        //                }
        //                var data = eval(data);
        //                var options = "";
        //                for (var i = 0; i < data.length; i++) {
        //                    options += "<option value='" + data[i].TypeId + "'>" + data[i].TypeText + "</option>";
        //                }
        //                $("#sel_bugtype").append($(options));
        //            })
        //        }

        //        function ChangeSel(obj) {
        //            SendAjax("get", requestUrl, { tag: "getbuglistbytype", ran: Math.random(), bugtype: $(obj).val() }, "json", function (data) {
        //                if (data == null) {
        //                    $("#tbody tr").each(function () {
        //                        $(this).remove();
        //                    })
        //                    return;
        //                }
        //                p.Init(data);
        //            });
        //        }

        //        function SearchBug() {
        //            if ($("#txt_name").val() == "") {
        //                return;
        //            }
        //            SendAjax("get", requestUrl, { tag: "searchlist", ran: Math.random(), bugtype: "0", title: $("#txt_name").val() }, "json", function (data) {
        //                if (data == null) {
        //                    $("#tbody tr").each(function () {
        //                        $(this).remove();
        //                    })
        //                    return;
        //                }
        //                p.Init(data);
        //            });
        //        }

        //        function loaddata(data) {
        //            if (data == null) {
        //                return;
        //            }
        //            $("#tbody tr").each(function () {
        //                $(this).remove();
        //            })
        //            var html = "";
        //            for (var i = 0; i < data.length; i++) {
        //                html += "<tr>";
        //                html += "<td>" + data[i].id + "</td>";
        //                html += "<td tag='" + data[i].id + "'><a target='_blank' id='" + data[i].id + "' href='EditReplys.aspx?bugid=" + data[i].id + "'>" + data[i].Title + "</a></td>";
        //                html += "<td title='" + data[i].Contents + "'>" + cutStr(data[i].Contents, 10) + "</td>";
        //                html += "<td><a href='javascript:void(0);' target='_blank' tagid='" + data[i].id + "' onclick='BugClick(this)'>Edit</a>&nbsp&nbsp";
        //                html += "<a href='javascript:void(0);' tagid='" + data[i].id + "' onclick='Del(this)'>Delete</a></td>";
        //                html += "</tr>";
        //            }
        //            $("#tbody").append($(html));
        //        }

        function EditClick(obj) {
            window.location.href = "EditReplys.aspx?bugid=" + $(obj).attr("id");
        }

        function DelClick(obj) {
            if (window.confirm("确认是否要删除?")) {
                SendAjax("post", requestUrl, { ran: Math.random(), tag: "delbug", id: $(obj).attr("tagid") }, "", function () {
                    window.location.href = window.location.href;
                });
            }
        }

        //        loadSelect();
    </script>
</asp:Content>
